﻿#region namespaces
using System;
using System.Configuration;
using System.Web;
#endregion

namespace SLIITPro.Core
{
    public static class CoreSettings
    {
        private static string _mySqlConnectionString;
        public static string MySqlConnectionString
        {
            get
            {
                return _mySqlConnectionString ??
                       (_mySqlConnectionString =
                       @"Data Source=HAWK\SQLEXPRESS;Persist Security Info=True;Integrated Security=SSPI;Initial Catalog=SLIITPro");
                // ConfigurationManager.ConnectionStrings["SLIITProConnectionString"].ConnectionString);
            }
        }

        #region System Path Settings

        private static string _globalBusinessImageRoot;
        public static string GlobalBusinessImageRoot
        {
            get
            {
                return _globalBusinessImageRoot ?? (_globalBusinessImageRoot = StorageLocation + "/BusinessImage/");
            }
        }

        private static string _absoluteUrl;
        public static string AbsoluteUrl
        {
            get
            {
                var context = HttpContext.Current;
                return _absoluteUrl ??
                       (_absoluteUrl =
                        new Uri(context.Request.Url.GetLeftPart(UriPartial.Authority) + RelativeWebRoot).
                            AbsoluteUri);
            }
        }

        private static string _storageLocation;
        public static string StorageLocation
        {
            get
            {
                return _storageLocation ?? (_storageLocation =
                                            VirtualPathUtility.ToAbsolute(
                                                ConfigurationManager.AppSettings["SLIITPro.ImageStorage"]));
            }
        }

        private static string _templateRoot;
        public static string TemplateRoot
        {
            get { return _templateRoot ?? (_templateRoot = RelativeWebRoot + "Controls/"); }
        }


        private static string _RelativeWebRoot;
        public static string RelativeWebRoot
        {
            get
            {
                return _RelativeWebRoot ?? (_RelativeWebRoot =
                                            VirtualPathUtility.ToAbsolute(
                                            ConfigurationManager.AppSettings["SLIITPro.VirtualPath"]));
            }
        }

        #endregion

    }

    public class EmailSettings
    {
        #region Email Settings

        private static string _fromMailAddress;
        public static string FromMailAddress
        {
            get
            {
                return _fromMailAddress ?? (_fromMailAddress = "sliitpro2@gmail.com");
            }
        }

        private static string _smtpClient;
        //smtpout.secureserver.net : 25
        //relay-hosting.secureserver.net : 25
        //smtp.gmail.com : 587
        public static string SmtpClient
        {
            get
            {
                return _smtpClient ?? (_smtpClient = "smtp.gmail.com");
            }
        }

        public enum SmtpPort
        {
            Gmail = 587,
            Gmail2 = 465,
            Godaddy = 25,
        }
        #endregion
    }
}
